1) Introduce new exception type XendInvalidDomain that maps to the high level
authoranthony@rhesis.austin.ibm.com <anthony@rhesis.austin.ibm.com>
Fri, 24 Mar 2006 13:31:12 +0000 (14:31 +0100)
committeranthony@rhesis.austin.ibm.com <anthony@rhesis.austin.ibm.com>
Fri, 24 Mar 2006 13:31:12 +0000 (14:31 +0100)
   XEND_INVALID_DOMAIN faultType.
2) Fix exception logic in XMLRPCServer
3) Fix TCP server
4) Remove catching of ProtocolError in main.py.  ProtocolErrors only occur
   when there is an exception in the exception handling code which shouldn't
   ever happen.  I've reproduced the error cases described by Ewan with
   xend_domain_setTargetMemory and once I fixed the exception logic, I get a
   normal faultType of 1 as would be expected.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
tools/python/xen/xend/XendError.py
tools/python/xen/xend/server/XMLRPCServer.py
tools/python/xen/xm/main.py

index efe7fe5e32a10c2efe5a361697441d468f4840fc..f78a71f0316378d6ff987d983e0b9bfe995bc91b 100644 (file)
@@ -19,6 +19,10 @@ from xmlrpclib import Fault
 
 import XendClient
 
+class XendInvalidDomain(Fault):
+    def __init__(self, value):
+        Fault.__init__(self, XendClient.ERROR_INVALID_DOMAIN, value)
+
 class XendError(Fault):
     
     def __init__(self, value):
index 1e553a84e340a2a0d9f14071c2d39d9b7bcd20cb..7d03cfb3dccb26a54f442121df66b3e33c92ca77 100644 (file)
@@ -23,35 +23,21 @@ from xen.xend import XendDomain, XendDomainInfo, XendNode, \
 from xen.util.xmlrpclib2 import UnixXMLRPCServer, TCPXMLRPCServer
 
 from xen.xend.XendClient import XML_RPC_SOCKET, ERROR_INVALID_DOMAIN
+from xen.xend.XendError import *
 
 def lookup(domid):
-    try:
-        return XendDomain.instance().domain_lookup_by_name_or_id(domid)
-    except exn:
-        log.exception(exn)
-        raise exn
+    info = XendDomain.instance().domain_lookup_by_name_or_id(domid)
+    if not info:
+        raise XendInvalidDomain(str(domid))
+    return info
 
 def dispatch(domid, fn, args):
     info = lookup(domid)
-    if info:
-        try:
-            return getattr(info, fn)(*args)
-        except exn:
-            log.exception(exn)
-            raise exn
-    else:
-        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
+    return getattr(info, fn)(*args)
 
 def domain(domid):
     info = lookup(domid)
-    if info:
-        try:
-            return info.sxpr()
-        except exn:
-            log.exception(exn)
-            raise exn
-    else:
-        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
+    return info.sxpr()
 
 def domains(detail=1):
     if detail < 1:
@@ -90,7 +76,7 @@ class XMLRPCServer:
         if self.use_tcp:
             # bind to something fixed for now as we may eliminate
             # tcp support completely.
-            self.server = TCPXMLRPCServer(("localhost", 8005, False))
+            self.server = TCPXMLRPCServer(("localhost", 8005), logRequests=False)
         else:
             self.server = UnixXMLRPCServer(XML_RPC_SOCKET, False)
 
index 6bb09b29f6ba4771a19891d709b812afe080ac73..a636dd5e84a4db0f8ca9afd353a58d17d34090c3 100644 (file)
@@ -1102,12 +1102,6 @@ def main(argv=sys.argv):
             else:
                 err("Error connecting to xend: %s." % ex[1])
             sys.exit(1)
-        except xmlrpclib.ProtocolError, ex:
-            if os.geteuid() != 0:
-                err("Most commands need root access.  Please try again as root.")
-            else:
-                err("Error connecting to xend: %s." % ex.errmsg)
-            sys.exit(1)
         except SystemExit:
             sys.exit(1)
         except xmlrpclib.Fault, ex: